package com.ethink.platform.controller.warehouse;

import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.platform.controller.order.info.ExportInfo;
import com.ethink.platform.manager.ExportManager;
import com.ethink.warehouse.api.MateInventoryOtherOutLogFacade;
import com.ethink.warehouse.api.info.MateInventoryOtherOutLogInfo;
import com.ethink.warehouse.api.info.MateInventoryOtherOutLogModeInfo;
import com.ethink.warehouse.api.request.MateInventoryOtherOutLogAddRequest;
import com.ethink.warehouse.api.request.MateInventoryOtherOutLogQueryRequest;
import com.ethink.warehouse.api.request.MateInventoryOtherOutLogUpdateRequest;
import com.ethink.warehouse.api.response.MateInventoryOtherOutLogDetailResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 其他出库 Controller
 *
 * @author default
 * @date 2023-02-08
 */
@Tag(name = "MateInventoryOtherOutLogController", description = "其他出库 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/warehouse-service")
public class MateInventoryOtherOutLogController extends BaseController {

    @Autowired
    private MateInventoryOtherOutLogFacade mateInventoryOtherOutLogFacade;

    @Autowired
    private ExportManager exportManager;

    @Operation(summary = "分页查询")
    @GetMapping("/mateInventoryOtherOutLog/query")
    public CommonResponse<List<MateInventoryOtherOutLogInfo>> queryMateInventoryOtherOutLog(MateInventoryOtherOutLogQueryRequest request) {
        return succeedWithPage(mateInventoryOtherOutLogFacade.queryMateInventoryOtherOutLog(request));
    }

    @Operation(summary = "导出")
    @GetMapping("/mateInventoryOtherOutLog/export")
    public CommonResponse<ExportInfo> exportMateInventoryOtherOutLogExcel(MateInventoryOtherOutLogQueryRequest request) {
        return succeedWith(exportManager.exportMateInventoryOtherOutLogExcel(request));
    }

    @Operation(summary = "货品模式分页查询")
    @GetMapping("/mateInventoryOtherOutLog/queryMode")
    public CommonResponse<List<MateInventoryOtherOutLogModeInfo>> queryMateInventoryOtherOutLogMode(MateInventoryOtherOutLogQueryRequest request) {
        return succeedWithPage(mateInventoryOtherOutLogFacade.queryMateInventoryOtherOutLogMode(request));
    }

    @Operation(summary = "货品模式导出")
    @GetMapping("/mateInventoryOtherOutLog/exportMode")
    public CommonResponse<ExportInfo> exportMateInventoryOtherOutLogModeExcel(MateInventoryOtherOutLogQueryRequest request) {
        return succeedWith(exportManager.exportMateInventoryOtherOutLogModeExcel(request));
    }

    @Operation(summary = "详情查询")
    @GetMapping("/mateInventoryOtherOutLog/get/{mateInventoryOtherOutLogId}")
    public CommonResponse<MateInventoryOtherOutLogDetailResponse> getMateInventoryOtherOutLogById(@PathVariable("mateInventoryOtherOutLogId") Long mateInventoryOtherOutLogId) {
        return succeedWith(mateInventoryOtherOutLogFacade.getMateInventoryOtherOutLogById(mateInventoryOtherOutLogId));
    }

    @Operation(summary = "查询所有")
    @GetMapping("/mateInventoryOtherOutLog/list")
    public CommonResponse<List<MateInventoryOtherOutLogInfo>> listMateInventoryOtherOutLog(MateInventoryOtherOutLogQueryRequest request) {
        return succeedWith(mateInventoryOtherOutLogFacade.listMateInventoryOtherOutLog(request));
    }

    @Operation(summary = "新增")
    @PostMapping("/mateInventoryOtherOutLog/add")
    public CommonResponse addMateInventoryOtherOutLog(@RequestBody MateInventoryOtherOutLogAddRequest request) {
        mateInventoryOtherOutLogFacade.addMateInventoryOtherOutLog(request);
        return succeed();
    }

    @Operation(summary = "更新")
    @PutMapping("/mateInventoryOtherOutLog/update")
    public CommonResponse updateMateInventoryOtherOutLog(@RequestBody MateInventoryOtherOutLogUpdateRequest request) {
        mateInventoryOtherOutLogFacade.updateMateInventoryOtherOutLog(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PutMapping("/mateInventoryOtherOutLog/delete/{mateInventoryOtherOutLogId}")
    public CommonResponse deleteMateInventoryOtherOutLog(@PathVariable("mateInventoryOtherOutLogId") Long mateInventoryOtherOutLogId) {
        mateInventoryOtherOutLogFacade.deleteMateInventoryOtherOutLog(mateInventoryOtherOutLogId);
        return succeed();
    }

    @Operation(summary = "审批通过(订单状态 = 2)")
    @PutMapping("/mateInventoryOtherOutLog/pass/{mateInventoryOtherOutLogId}")
    public CommonResponse mateInventoryOtherOutLogPass(@PathVariable Long mateInventoryOtherOutLogId) {
        mateInventoryOtherOutLogFacade.mateInventoryOtherOutLogPass(mateInventoryOtherOutLogId);
        return succeed();
    }

    @Operation(summary = "审批拒绝(订单状态 = 2)")
    @PutMapping("mateInventoryOtherOutLog/refuse/{mateInventoryOtherOutLogId}")
    public CommonResponse mateInventoryOtherOutLogRefuse(@PathVariable Long mateInventoryOtherOutLogId) {
        mateInventoryOtherOutLogFacade.mateInventoryOtherOutLogRefuse(mateInventoryOtherOutLogId);
        return succeed();
    }

}